<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script src="json2.js"></script>
</head>
<body>
<script>
	window.onload = function(){
		var oBtn = document.getElementById('btn');
		oBtn.onclick = function(){
			var xhr = new XMLHttpRequest();
			xhr.open('get','getNews.php','false');
			xhr.send();
			xhr.onreadystatechange = function(){
				if (xhr.readyState == 4) {
					if (xhr.status == 200) {
						var date = JSON.parse(xhr.responseText);
						var html = '';
						var oUl = document.getElementById('ul');
						for(var i=0;i<date.length;i++){
							html+='<li><a href="">'+date[i].title+'</a>[<span>'+date[i].date+'</span>]</li>'
						}
						oUl.innerHTML = html;

					}else{
						alert('出错了，Err:'+xhr.status);
					}
				}
			}
		}

	}
</script>
	<input type="button" value="按钮" id="btn">
	<ul id="ul"></ul>
</body>
</html>